home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / c_doc.arc / C_DOC.M
Encoding:
Text File  |  1987-03-10  |  5.8 KB  |  132 lines

  1. ;*****************************************************************************
  2. ;*            (c) COPYRIGHT LIFE SCIENCES, INC. 1987, ALL RIGHTS RESERVED     **
  3. ;*****************************************************************************
  4. ;**    This macro is released for use but may not be included in any
  5. ;**    package sold for commercial gain.
  6. ;**
  7. ;**                                 Douglas Hill
  8. ;**                                Life Sciences, Inc
  9. ;**                                RR1, Box 37F
  10. ;**                                 W. Lebanon, NH  03784
  11. ;**                                 (603) 298-8010
  12. ;**
  13. ;**          NOTE: needs BRIEF v1.33 for the "date" function
  14. ;** C_DOC creates and updates a functional description, modification history,
  15. ;** and copyright notice for c programs.  This is the easiest way I know for
  16. ;** a team of programmers to keep each other informed of changes they have
  17. ;** made.  The uniform format also makes it possible to write programs to
  18. ;** extract the change notices from all the c files in a directory, sort them
  19. ;** and produce lists of changes made in a project arranged by date, author,
  20. ;** or module.  (If you write such a program, you might send me a copy.)
  21. ;**
  22. ;** The first time C_DOC is invoked on a given file, it creates the outline
  23. ;** of a functional description and copyright notice, giving your name as
  24. ;** author and the current date as the creation date.  It inserts the name
  25. ;** of the file and leaves you in a position to describe the file name.  I
  26. ;** find this useful for explaining cryptic filenames, like pbtoouts.c -
  27. ;** Paste Buffer to Output String.
  28. ;** 
  29. ;** The next time c_doc is invoked on the file, it will leave you in a position
  30. ;** to describe the functions of the procedures in the file.
  31. ;** 
  32. ;** All subsequent invocations will add your name and the date to the
  33. ;** modification history and leave you in a position to describe the change.
  34. ;** If the current year is later than the latest year on the copyright notice
  35. ;** the notice will be updated.
  36. ;** 
  37. ;** I assign C_DOC to a key and press it once when I have just created the
  38. ;** file (and the rationale for that file name is still fresh), once to
  39. ;** describe how the functions are called, what they do and what they return,
  40. ;** and then any time I make a change worth recording.
  41. ;** 
  42. ;** C_DOC needs to know two things, the current author's name, and the name
  43. ;** to use as the copyright owner.  (If the copyright owner name changes, the
  44. ;** copyright date will not be updated with changes.)
  45. ;** You may insert these into the program as shown below, or put them in the
  46. ;** environmental variables C_AUTHOR and C_OWNER.  For example,
  47. ;** SET C_AUTHOR=Doug Hill
  48. ;** You must exit Brief to set these; if you just pop out temporarily to set
  49. ;** them, they'll be gone when you type "exit".  If the environmental strings
  50. ;** exist, they will take precedence over the names defined below.
  51. ;**
  52. ;** Thanks to Wendin, Inc.  This format is similar to the modification history
  53. ;** in their Operating System Toolbox (TM).
  54.  
  55. (macro c_doc
  56.    (
  57.       (string bname date_str year_str copy_str new_copy_str
  58.               tem_str owner author)
  59.       (int year month day)
  60.  
  61.       (= author (inq_environment "C_AUTHOR"))
  62.       (if (== (strlen author) 0)
  63.          (= author "D. P. Hill")         ;** PUT YOUR NAME HERE **
  64.       )
  65.       (= owner (inq_environment "C_OWNER"))
  66.       (if (== (strlen owner) 0)
  67.          (= owner "Life Sciences, Inc.") ;** PUT COPYRIGHT OWNER HERE **
  68.       )
  69.  
  70.       (date year month day)        ;** modify these 3 lines to put date
  71.       (sprintf year_str "%d" year) ;** in the format you like
  72.       (sprintf date_str "%02d/%02d/%s" month day (substr year_str 3))
  73.  
  74.       (move_abs 1 1)             ;** move to beginning of file
  75.       (if (<= (search_fwd "Modification history") 0)  ;** if no header yet
  76.          (                       ;** create it
  77.             (insert "/*\n")
  78.             (insert "1.      Proc name.\n\n\n")
  79.             (insert "2.      Functional description.\n\n")
  80.             (insert "3.      Modification history.\n")
  81.             (sprintf tem_str "        %s\n\n\n" author)
  82.             (insert tem_str)
  83.             (sprintf tem_str
  84.                "4.      NOTICE:  Copyright (C) %d %s\n*/\n" year owner
  85.             )
  86.             (insert tem_str)
  87.             (move_abs 8 25)      ;** put in date
  88.             (insert date_str)
  89.             (end_of_line)
  90.             (insert "  Creation")
  91.             (move_rel 1 0)
  92.             (delete_line)
  93.             (move_abs 3 9)       ;** add name of file
  94.             (inq_names NULL NULL bname);  ;** get name of buffer
  95.             (insert bname)
  96.             (insert " - ")       ;** leave cursor after name
  97.          )
  98.          ;else                   ;** modification history exists - add to it
  99.          (
  100.             (save_position)
  101.             (sprintf copy_str "%d %s" year owner) ;** update copyright message
  102.             (if (< (search_fwd copy_str 0) 1)  ;** if message not current
  103.                (
  104.                   (sprintf copy_str "19{??} %s" owner)
  105.                   (sprintf new_copy_str "19\\0, %d %s" year owner)
  106.                   (translate copy_str new_copy_str 0)
  107.                )
  108.             )
  109.             (restore_position)
  110.             (move_rel -2 -8)
  111.             (if (== (read 2) "2.")  ;** haven't described function yet
  112.                (
  113.                   (end_of_line)
  114.                   (insert "\n        ")
  115.                )
  116.                ;else       ;** add next modification
  117.                (
  118.                   (search_fwd "4.")
  119.                   (move_rel -1 8)
  120.                   (insert author)
  121.                   (move_abs 0 25)
  122.                   (insert ( + date_str "\n"))
  123.                   (move_rel -1 0)
  124.                   (end_of_line)
  125.                   (insert "  ") ;** leave cursor here for change description
  126.                )
  127.             )
  128.          )
  129.       )
  130.    )
  131. )
  132.